package com.zhuhjay.common.web.config;

import com.zhuhjay.common.base.config.SystemConfig;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.ApplicationRunner;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author ZhuHJay
 * @date 2023/2/24 23:24
 */
@Slf4j
@Configuration
public class SystemAppRunner {

    /** 项目启动完成后打印一些常用的地址方便启用 **/
    @Bean
    public ApplicationRunner consoleLogRunner(SystemConfig constant) {
        String version = constant.getVersion();
        String name = constant.getName();
        return arg ->
                log.info(
                        "\n-------------- {}启动完成 --------------\n" +
                                "作者   :\t{}\n" +
                                "版本   :\t{}\n" +
                                "提供以下访问路径:\n" +
                                    "\tAPI文档:\t{}\n" +
                        "-------------- {}启动完成 --------------\n",
                        name, '@' + constant.getAuthor(), version,
                        "http://127.0.0.1:" + constant.getPort() + "/doc.html",
                        name
                );
    }

}
